package fzu.functiongather.DropDownMenu;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;

import java.util.ArrayList;
import java.util.List;

import fzu.functiongather.Adapter.SpinerAdapter;
import fzu.functiongather.BaseActivity;
import fzu.functiongather.R;
import fzu.functiongather.mUtils.SpinnerPopup;

/**
 * Created by Administrator on 2016/11/25.
 */
public class DropDownMenuActivity extends BaseActivity implements SpinerAdapter.IOnItemSelectListener{
    private List<String> mListType = new ArrayList<String>();  //类型列表
    private SpinerAdapter spinerAdapter;
    private SpinnerPopup spinnerPopup;
    private LinearLayout ll_homepage_time_tvAim;
    String[] listDatasTime = new String[]{"全部","同区","同楼","同层",};
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dropdown_menu_activity);
        ll_homepage_time_tvAim=(LinearLayout)findViewById(R.id.ll_homepage_time_tvAim);
        ll_homepage_time_tvAim.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mListType = new ArrayList<String>();
                creatSpinner(listDatasTime);
                showSpinWindow(ll_homepage_time_tvAim);
            }
        });
    }
    private void creatSpinner(String listData[]){

        for(int i = 0; i < listData.length; i++){
            mListType.add(listData[i]);
        }

        spinerAdapter = new SpinerAdapter(DropDownMenuActivity.this,mListType);
        spinerAdapter.refreshData(mListType, 0);

        //显示第一条数据
        //mTView.setText(names[0]);

        //初始化PopWindow
        spinnerPopup = new SpinnerPopup(DropDownMenuActivity.this);
        spinnerPopup.setAdatper(spinerAdapter);
        spinnerPopup.setItemListener(this);
    }
    private void showSpinWindow(LinearLayout mLinearLayout){
        Log.e("", "showSpinWindow");
        spinnerPopup.setWidth(mLinearLayout.getWidth());
        spinnerPopup.showAsDropDown(mLinearLayout);
    }
    @Override
    public void onItemClick(int pos) {

    }
}
